package by.msokoloff.javaweb2015.webapp.page;

import org.apache.wicket.markup.html.panel.Panel;

import by.msokoloff.javaweb2015.datamodel.AbstractEntity;
import by.msokoloff.javaweb2015.datamodel.AdmUser;
import by.msokoloff.javaweb2015.datamodel.Airport;
import by.msokoloff.javaweb2015.datamodel.City;
import by.msokoloff.javaweb2015.datamodel.Country;
import by.msokoloff.javaweb2015.datamodel.Extra;
import by.msokoloff.javaweb2015.datamodel.Flight;
import by.msokoloff.javaweb2015.datamodel.Plane;
import by.msokoloff.javaweb2015.datamodel.PlaneModel;
import by.msokoloff.javaweb2015.datamodel.Registration;
import by.msokoloff.javaweb2015.datamodel.TripOrder;
import by.msokoloff.javaweb2015.webapp.page.admuser.AdmUserEditPanel;
import by.msokoloff.javaweb2015.webapp.page.airport.AirportEditPanel;
import by.msokoloff.javaweb2015.webapp.page.city.CityEditPanel;
import by.msokoloff.javaweb2015.webapp.page.country.CountryEditPanel;
import by.msokoloff.javaweb2015.webapp.page.extra.ExtraEditPanel;
import by.msokoloff.javaweb2015.webapp.page.flight.FlightEditPanel;
import by.msokoloff.javaweb2015.webapp.page.layout.AdminLayout;
import by.msokoloff.javaweb2015.webapp.page.plane.PlaneEditPanel;
import by.msokoloff.javaweb2015.webapp.page.planemodel.PlaneModelEditPanel;
import by.msokoloff.javaweb2015.webapp.page.registration.RegistrationEditPanel;
import by.msokoloff.javaweb2015.webapp.page.triporder.TripOrderEditPanel;

public class EntityEditPage extends AdminLayout {

	private Panel panel;

	public EntityEditPage(AbstractEntity e) {
		if (e.getClass() == Country.class) {
			panel = new CountryEditPanel("editpanel", (Country) e);
		} else if (e.getClass() == City.class) {
			panel = new CityEditPanel("editpanel", (City) e);
		} else if (e.getClass() == Airport.class) {
			panel = new AirportEditPanel("editpanel", (Airport) e);
		} else if (e.getClass() == PlaneModel.class) {
			panel = new PlaneModelEditPanel("editpanel", (PlaneModel) e);
		} else if (e.getClass() == Plane.class) {
			panel = new PlaneEditPanel("editpanel", (Plane) e);
		} else if (e.getClass() == Flight.class) {
			panel = new FlightEditPanel("editpanel", (Flight) e);
		} else if (e.getClass() == TripOrder.class) {
			panel = new TripOrderEditPanel("editpanel", (TripOrder) e);
		} else if (e.getClass() == Registration.class) {
			panel = new RegistrationEditPanel("editpanel", (Registration) e);
		} else if (e.getClass() == Extra.class) {
			panel = new ExtraEditPanel("editpanel", (Extra) e);
		} else if (e.getClass() == AdmUser.class) {
			panel = new AdmUserEditPanel("editpanel", (AdmUser) e);
		} else {
			// TODO compose exception
		}
		add(panel);
	}
}
